define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'order/orderimage/index',
                    add_url: 'order/orderimage/add',
                    edit_url: 'order/orderimage/edit',
                    del_url: 'order/orderimage/del',
                    multi_url: 'order/orderimage/multi',
                    table: 'order_image',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'image_id',
                sortName: 'image_id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'image_id', title: __('Image_id')},
                        {field: 'order_id', title: __('Order_id')},
                        {field: 'auth_status', title: __('Auth_status')},
                        {field: 'payment_img', title: __('Payment_img')},
                        {field: 'payed_img', title: __('Payed_img')},
                        {field: 'enjoyed_img', title: __('Enjoyed_img')},
                        {field: 'one_house', title: __('One_house')},
                        {field: 'two_house', title: __('Two_house')},
                        {field: 'three_house', title: __('Three_house')},
                        {field: 'pro_search_img', title: __('Pro_search_img')},
                        {field: 'main_cat_img', title: __('Main_cat_img')},
                        {field: 'main_img_up', title: __('Main_img_up')},
                        {field: 'main_img_mid', title: __('Main_img_mid')},
                        {field: 'main_img_low', title: __('Main_img_low')},
                        {field: 'pro_collect_img', title: __('Pro_collect_img')},
                        {field: 'store_collect_img', title: __('Store_collect_img')},
                        {field: 'fake_chat_img', title: __('Fake_chat_img')},
                        {field: 'on_time', title: __('On_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});